#include<bits/stdc++.h>
#define int long long
#define endl "\n"

using namespace std;

struct ty {
	int a, c;
	int pos;
};

bool cmp(ty x, ty y) {
	if(x.a != y.a) {
		return x.a < y.a;
	} else {
		return x.c > y.c;
	}
}

signed main() {
	int n;
	cin >> n;
	ty a[n + 10];
	for(int i = 1; i <= n; i ++ ) {
		cin >> a[i].a >> a[i].c;
		a[i].pos = i;
	}
	sort(a + 1, a + n + 1, cmp);
	vector<ty>v;
	int ta, tc;
	for(int i = 1; i <= n; i ++ ) {
		
	}
	cout << v.size() << endl;
	for(int i = 0; i < v.size(); i ++ ) {
		cout << v[i] << " ";
	}
	return 0;
}
